﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    CodeFile="CreateContract.aspx.cs" Inherits="CreateContract" Title="新建合同" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder" runat="Server">

    <script type="text/javascript">
function InvokePopSetCTI(report_id)
{
        // to handle in IE 7.0          
        if (window.showModalDialog)
        {      
            retVal = window.showModalDialog("SetCTI.aspx?report_id=" + report_id  ,'设定合同检验项',"dialogHeight:400px;dialogWidth:600px;resizable:no;center:yes");
            
        }
        // to handle in Firefox
        else
        {     
            retVal = window.open("SetCTI.aspx?report_id="+report_id ,'设定合同检验项','height=400,width=600,resizable=yes,modal=yes');
                 
        }  
        //window.location.href=window.location.pathname+"?co_item_id="+co_item_id;     
        return true;
         
}

function InvokePopSetCGB(report_id)
{
        // to handle in IE 7.0          
        if (window.showModalDialog)
        {      
            retVal = window.showModalDialog("SetCGB.aspx?report_id=" + report_id  ,'设定合同检验依据(GB)',"dialogHeight:400px;dialogWidth:600px;resizable:no;center:yes");
            
        }
        // to handle in Firefox
        else
        {     
            retVal = window.open("SetCGB.aspx?report_id="+report_id ,'设定合同检验依据(GB)','height=400,width=600,resizable=yes,modal=yes');
                 
        }  
        //window.location.href=window.location.pathname+"?co_item_id="+co_item_id;     
        return true;
         
}
//上传样品参数文件,必须创建合同之后，才能够上传参数文件
function InvokePopUploadParFile(report_id)
{
 
    var url= 'uploadfile2.aspx?parameterfile&pccid='+'<%=this.BtnUploadParFileHidden.ClientID%>'+'&report_id='+report_id ;
    window.open(url,'上传','height=400,width=600,resizable=yes');             
  
}


//上传原始记录文件
function InvokePop(co_item_id)
{
      var url='uploadfile2.aspx?co_testitem_xls&pccid='+'<%=this.btnHiddenAddTRFile.ClientID%>'+'&co_item_id='+co_item_id;

      window.open(url,'上传','height=400,width=600,resizable=yes');

         
}
//上传报告文件
function InvokePopUploadFinalReport(report_id)
{
    var url= 'uploadfile2.aspx?report&pccid='+'<%=this.BtnUploadReportHidden.ClientID%>'+'&id='+report_id ;
    window.open(url,'上传','height=400,width=600,resizable=yes');                
  
}

//下载模板
function InvokePopDownloadTemplate(item_code,co_item_id)
{
        // to handle in IE 7.0          
        if (window.showModalDialog)
        {      
            retVal = window.showModalDialog("TestItemTemplate.aspx?item_code=" + item_code  ,'下载原始记录模板(Excel格式)',"dialogHeight:400px;dialogWidth:600px;resizable:no;center:yes;");
            
        }
        // to handle in Firefox
        else
        {     
            retVal = window.open("TestItemTemplate.aspx?item_code=" + item_code  ,'下载原始记录模板(Excel格式)','height=400,width=600,resizable=yes,modal=yes');
                 
        }  
       // window.location.href=window.location.pathname+"?co_item_id="+co_item_id;     
         return true;
}


function InvokePopSelectAuditor(report_id,flow)
{
  // to handle in IE 7.0          
        if (window.showModalDialog)
        {      
            retVal = window.showModalDialog("SelectAuditors.aspx?report_id=" + report_id+"&flow="+flow  ,'选择审批人',"dialogHeight:600px;dialogWidth:800px;resizable:no;center:yes");
            
        }
        // to handle in Firefox
        else
        {     
            retVal = window.open("SelectAuditors.aspx?report_id=" + report_id+"&flow="+flow  ,'选择审批人','height=600px,width=800px,resizable=yes,modal=yes');
                 
        }  
       // window.location.href=window.location.pathname+"?co_item_id="+co_item_id;     
         return true;
}




function OpenWindow(url)
        {
            // to handle in IE 7.0          
            if (window.showModalDialog)
            {      
                retVal = window.showModalDialog(url ,'newwindow',"dialogHeight:500px;dialogWidth:800px;resizable:no;center:yes;");
            }
            // to handle in Firefox
            else
            {     
                retVal = window.open(url,'newwindow','height=500,width=600,resizable=yes,modal=yes');
            }  
            //window.location.href=window.location.pathname+"?co_item_id="+co_item_id; 
            //alert(retVal);    
            var o=eval('('+retVal+')');
            //alert(o.name);
            document.getElementById('<%=textBoxClientID.ClientID%>').value=o.client_id;
            document.getElementById('<%=textBoxCorp_Name.ClientID%>').value=o.corp_name;
            document.getElementById('<%=textBoxConsigner.ClientID%>').value=o.consigner;
            document.getElementById('<%=textBoxFax.ClientID%>').value=o.fax;
            document.getElementById('<%=textBoxLinkman.ClientID%>').value=o.linkman;
            document.getElementById('<%=textBoxPhone.ClientID%>').value=o.phone;
            document.getElementById('<%=textBoxEmail.ClientID%>').value=o.email;
            
            return true;
        }
 function ResetClientInfo()
 {
            document.getElementById('<%=textBoxClientID.ClientID%>').value="";
            document.getElementById('<%=textBoxCorp_Name.ClientID%>').value="";
            document.getElementById('<%=textBoxConsigner.ClientID%>').value="";
            document.getElementById('<%=textBoxFax.ClientID%>').value="";
            document.getElementById('<%=textBoxLinkman.ClientID%>').value="";
            document.getElementById('<%=textBoxPhone.ClientID%>').value="";
            document.getElementById('<%=textBoxEmail.ClientID%>').value="";
 
 
 }
        
    </script>

    <h1 id="pagetitle" class="pagetitle">
        合同编辑
        <asp:UpdateProgress ID="UpdateProgress1" runat="server">
            <ProgressTemplate>
                <div class="anistyle" id="ani">
                    正在加载数据，请耐心等待...
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
    </h1>
    <strong>合同状态：<asp:Label ID="LabelContractStatus" runat="server" Text=""></asp:Label></strong>
 
    <table width="100%" id="table1" runat="server" border="1">
        <tr>
            <th rowspan="8">
                客户信息</th>
            <th>
                客户编号</th>
            <td>
                <asp:TextBox ID="textBoxClientID" ReadOnly="true" runat="server" EnableViewState="true"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <th>
                客户单位</th>
            <td>
                <asp:TextBox ID="textBoxCorp_Name" runat="server"></asp:TextBox></td>
        </tr>
        <tr>
            <th>
                委托人姓名</th>
            <td>
                <asp:TextBox ID="textBoxConsigner" runat="server"></asp:TextBox></td>
        </tr>
        <tr>
            <th>
                联系人姓名</th>
            <td>
                <asp:TextBox ID="textBoxLinkman" runat="server"></asp:TextBox></td>
        </tr>
        <tr>
            <th>
                联系电话</th>
            <td>
                <asp:TextBox ID="textBoxPhone" runat="server"></asp:TextBox></td>
        </tr>
        <tr>
            <th>
                传真</th>
            <td>
                <asp:TextBox ID="textBoxFax" runat="server"></asp:TextBox></td>
        </tr>
        <tr>
            <th>
                E-Mail</th>
            <td>
                <asp:TextBox ID="textBoxEmail" runat="server"></asp:TextBox></td>
        </tr>
        <tr>
            <th>
                操作</th>
            <td>
                <span id="BtnReset" runat="server">
                    <input id="Button1" type="button" value="重置" onclick="javascript:ResetClientInfo()" /></span>
                <%--<asp:Button ID="BtnReset" runat="server" Text="重置" OnClientClick= "javascript:ResetClientInfo()" />--%>
                <span id="BtnSelectClient" runat="server">
                    <input id="Button2" type="button" value="选择客户" onclick="javascript:OpenWindow('selectclientinfo.aspx')" /></span>
                <%--<asp:Button ID="BtnSelectClient" runat="server" Text="选择客户" OnClientClick="javascript:OpenWindow('selectclientinfo.aspx')"  />--%>
                <asp:Button ID="BtnGoToSetp2" runat="server" Text="保存客户信息" OnClick="BtnGoToSetp2_Click" />
            </td>
        </tr>
    </table> 
    
    <table width="100%" id="table2" runat="server" border="1" visible="true">
        <tr>
            <th>
                样品参数</th>
            <td colspan="2">
                <asp:GridView ID="GridViewParametersFile" runat="server" Width="100%" AutoGenerateColumns="False"
                    DataKeyNames="Sample_ID" CellPadding="4" ForeColor="#333333" GridLines="None">
                    <RowStyle Height="20px" BackColor="#EFF3FB" />
                    <HeaderStyle BackColor="#507CD1" ForeColor="White" Height="24px" Font-Bold="True" />
                    <AlternatingRowStyle BackColor="White" />
                    <Columns>
                        <asp:BoundField DataField="Ref_Par_File" HeaderText="编号" />
                        <asp:BoundField DataField="File_Name" HeaderText="文件名称" />
                        <asp:BoundField DataField="File_Create_Time" DataFormatString="{0:d}" HeaderText="创建时间" />
                        <asp:HyperLinkField DataNavigateUrlFields="Ref_Par_File" DataNavigateUrlFormatString="getfile.aspx?fileid={0}"
                            HeaderText="下载" Target="_blank" Text="下载" />
                        <asp:TemplateField HeaderText="操作">
                            <ItemTemplate>
                                &nbsp;<asp:LinkButton ID="GvDelete" runat="server" OnClick="GvDeleteParametersFile_Click">删除</asp:LinkButton>
                                <%-- <asp:LinkButton ID="GvDetail" runat="server" OnClick="GvDetail_Click">详细</asp:LinkButton>--%>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="100px" />
                        </asp:TemplateField>
                    </Columns>
                    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                    <EditRowStyle BackColor="#2461BF" />
                </asp:GridView>
                <asp:Button ID="btnUploadParFile" runat="server" Text="上传参数文件" />
                <asp:Button ID="BtnUploadParFileHidden" Text="" runat="server" Style="display: none"
                    OnClick="btnUploadParFile_Click" /></td>
        </tr>
        <%--  检验依据--%>
        <tr>
            <th>
                检验依据</th>
            <td colspan="2">
                <asp:GridView ID="GridViewGbInfo" runat="server" Width="100%" AutoGenerateColumns="False"
                    DataKeyNames="GB_Code" CellPadding="4" ForeColor="#333333" GridLines="None">
                    <RowStyle Height="20px" BackColor="#EFF3FB" />
                    <HeaderStyle BackColor="#507CD1" ForeColor="White" Height="24px" Font-Bold="True" />
                    <AlternatingRowStyle BackColor="White" />
                    <Columns>
                        <asp:BoundField DataField="GB_Code" HeaderText="检验依据代码" />
                        <asp:BoundField DataField="GB_Title" HeaderText="检验依据名称" />
                        <asp:TemplateField HeaderText="操作">
                            <ItemTemplate>
                                &nbsp;<asp:LinkButton ID="GvDelete" runat="server" OnClick="GvDeleteGbInfo_Click">移除</asp:LinkButton>
                                <%-- <asp:LinkButton ID="GvDetail" runat="server" OnClick="GvDetail_Click">详细</asp:LinkButton>--%>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="100px" />
                        </asp:TemplateField>
                    </Columns>
                    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                    <EditRowStyle BackColor="#2461BF" />
                </asp:GridView>
                <%--后台设定Client端脚本调用，服务器端调用随后发生--%>
                <asp:Button ID="BtnSelectGbInfo" runat="server" Text="添加检验依据" OnClick="BtnSelectGbInfo_Click" />
            </td>
        </tr>
        <%--检验项目--%>
        <tr>
            <th rowspan="2">
                检验项目</th>
            <td colspan="2">
                <asp:GridView ID="GridViewCoTestItem" runat="server" Width="100%" AutoGenerateColumns="False"
                    DataKeyNames="Co_Item_ID" CellPadding="4" ForeColor="#333333" GridLines="None"
                    OnRowDataBound="GridViewCoTestItem_RowDataBound">
                    <RowStyle Height="20px" BackColor="#EFF3FB" />
                    <HeaderStyle BackColor="#507CD1" ForeColor="White" Height="24px" Font-Bold="True" />
                    <AlternatingRowStyle BackColor="White" />
                    <Columns>
                        <asp:BoundField DataField="Item_Code" HeaderText="检验项目代码" />
                        <asp:BoundField DataField="Item_Title" HeaderText="检验项目名称" />
                        <asp:BoundField DataField="Price" HeaderText="价格" />
                        <asp:BoundField DataField="Opt_Dept" HeaderText="执行部门" />
                        <asp:TemplateField HeaderText="操作">
                            <ItemTemplate>
                                <asp:LinkButton ID="LBDelTestItem" runat="server" CommandName="del_test_item" Text="移除">移除</asp:LinkButton>
                                &nbsp; &nbsp;
                                <asp:LinkButton ID="LBDownloadTemplate" runat="server" CommandName="upload_test_record">下载模板</asp:LinkButton>
                                &nbsp; &nbsp;
                                <asp:LinkButton ID="LBUploadTestRecord" runat="server" CommandName="upload_test_record">上传原始记录</asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                    <EditRowStyle BackColor="#2461BF" />
                </asp:GridView>
                <asp:Button ID="btnHiddenAddTRFile" Text="" runat="server" Style="display: none"
                    OnClick="btnHiddenAddTRFile_Click" />
            </td>
        </tr>
        <tr>
            <td>
                <strong>
                    <asp:Label ID="LabelPriceSummary" runat="server"></asp:Label></strong>
                <asp:Button ID="btnSelectTestItem" runat="server" Text="设定检验项目" OnClick="btnSelectTestItem_Click" /></td>
            <td align="right">
                <asp:Button ID="BtnFixContract" ToolTip="合同一旦确认签订，则不可更改！" runat="server" Text="确认签订合同"
                    Font-Bold="True" OnClick="BtnFixContract_Click" OnClientClick='return confirm("确认后的合同将无法变更，您确认已经完成合同检验项和价格的设定了吗？\n单击【确定】继续，单击【取消】返回。");' />
            </td>
        </tr>
    </table>
    <%--原始记录--%>
    <table width="100%" runat="server" id="table3" border="1">
        <tr>
            <th>
                原始记录
            </th>
            <td colspan="2">
                <asp:GridView ID="GridViewTestRecords" runat="server" AutoGenerateColumns="False"
                    CellPadding="4" DataKeyNames="TR_ID" GridLines="None" 
                    Width="100%" Height="100%" ForeColor="#333333" OnRowDataBound="GridViewTestRecords_RowDataBound">
                    <Columns>
                        <asp:BoundField DataField="Item_Code" HeaderText="检验项代码" />
                        <asp:BoundField DataField="Item_Title" HeaderText="检验项名称" />
                        <asp:HyperLinkField DataNavigateUrlFields="TR_URL" DataNavigateUrlFormatString="getfile.aspx?fileid={0}"
                            DataTextField="Xls_Name" HeaderText="原始记录文件" Target="_blank" />
                        <asp:HyperLinkField DataNavigateUrlFields="Report_Slice_URL" DataNavigateUrlFormatString="getfile.aspx?fileid={0}"
                            DataTextField="Doc_Name" HeaderText="报告片段文件" Target="_blank" />
                        <asp:BoundField DataField="Dept_NAME" HeaderText="执行部门" />
                        <asp:BoundField DataField="Test_Finish_Date" HeaderText="更新时间" />
                  
                        <asp:TemplateField HeaderText="操作">
                            <ItemTemplate>
                            <asp:LinkButton ID="GvDeleteTestRecords" runat="server" OnClick="GvDeleteTestRecords_Click" OnClientClick="return confirm('您确认删除该原始记录文件吗?')">移除</asp:LinkButton>
                              
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="100px" />
                        </asp:TemplateField>
                    </Columns>
                    <RowStyle BackColor="#EFF3FB" />
                    <FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True" />
                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <AlternatingRowStyle BackColor="White" />
                    <EditRowStyle BackColor="#2461BF" />
                </asp:GridView>
            </td>
        </tr>
        <tr><td colspan="3"><asp:Label ID="LabelTaskStatus" runat="server" Text=""></asp:Label>
        <asp:Button ID="BtnConfirmTaskDone" runat="server" Text="确认本实验组检验任务完成" OnClick="BtnConfirmTaskDone_Click" OnClientClick="return confirm('确认本组试验完成之后，将不能再上传原始记录及进行任何试验操作。您确认本组试验完成了吗?')"/>
        </td>  </tr>
    </table>
    
    <%--检验报告--%>
    <table runat="server" id="table4" border="1">
        <tbody>
            <tr>
                <th rowspan="2">
                    检验报告
                </th>
                <th>
                    报告编号</th>
                <th>
                    报告文件名称</th>
                <th>
                    上传时间</th>
               <%-- <th style="width: 158px">
                    上传者 
                </th>--%>
                <th>
                    下载</th>
                <th>
                    删除</th>
                <td rowspan="2">
                    <asp:Button ID="BtnUploadReport" runat="server" Text="上传" />
                    <asp:Button ID="BtnUploadReportHidden" Text="" runat="server" Style="display: none"
                        OnClick="BtnUploadReport_Click" /></td>
                <td rowspan="2">
                    <asp:Button ID="BtnSendBackTestGrp" runat="server" OnClientClick='return confirm("您确认将实现结果退回吗？提示：退回实验即是要求各测试组重新做实验，请慎重退回。");' Text="退回实验组" OnClick="BtnSendBackTestGrp_Click" />
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="LabelReportId" runat="server"></asp:Label></td>
                <td>
                    <asp:Label ID="LabelReportName" runat="server"></asp:Label></td>
                <td>
                    <asp:Label ID="LabelUploadTime" runat="server"></asp:Label>
                </td>
               <%-- <td style="width: 158px">
                    <asp:Label ID="LabelUploader" runat="server"></asp:Label>
                </td>--%>
                <td>
                    <asp:HyperLink ID="HyperLinkReport" runat="server" Text="下载"></asp:HyperLink>
                </td>
                <td>
                    <asp:Button ID="BtnDeleteReport" runat="server" Text="删除" OnClientClick='return confirm("您确认删除该最终报告文件吗?提示：仅当您要重新上传最终报告文件时才删除。");'
                        OnClick="BtnDeleteReport_Click" />
                </td>
            </tr>
        </tbody>
    </table>
    <%--报告审核设置--%>
    <table width="100%" id="table5" border="1" runat="server">
        <tr>
            <th rowspan="3">
                报告审核</th>
            <th>
                专家审核成员</th>
            <th>
                站长审核成员</th>
                 <td rowspan="3"><asp:Button ID="BtnToWaitConfirm1" runat="server" Text="报告整理完成" OnClick="BtnToWaitConfirm1_Click" /></td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="LabelExperts" runat="server"></asp:Label></td>
            <td>
                <asp:Label ID="LabelMasters" runat="server"></asp:Label></td>
               
        </tr>
        <tr>
            <td>
                <asp:Button ID="BtnSelectExperts" runat="server" Text="成员设置" OnClick="BtnSelectAuditor_Click" />
                
                </td>
            <td>
                <asp:Button ID="ButtonSelectMaster" runat="server" Text="成员设置" OnClick="BtnSelectAuditor_Click" /></td>
        </tr>
    </table>
    <%-- 专家审核  --%>
    <table width="100%" id="table6" runat="server" border="1">
        <tr>
            <th rowspan="3">
                专家审核</th>
            <th>
                操作</th>
            <th>
                审核批注</th>
        </tr>
        <tr>
            <td>
                <asp:Button ID="BtnConfirm1" runat="server" Text="通过" OnClick="BtnConfirm1_Click" /></td>
            <td rowspan="2">
                <asp:TextBox ID="TextBoxRem1" runat="server" TextMode="MultiLine" Width="100%" Height="100%"></asp:TextBox></td>
        </tr>
        <tr>
            <td>
                <asp:Button ID="BtnRefuse1" runat="server" Text="否决" OnClick="BtnRefuse1_Click" /></td>
        </tr>
    </table>
    <%-- 站长审核  --%>
    <table width="100%" id="table7" runat="server" border="1">
        <tr>
            <th rowspan="3">
                站长审核</th>
            <th>
                操作</th>
            <th>
                审核批注</th>
        </tr>
        <tr>
            <td>
                <asp:Button ID="BtnConfirm2" runat="server" Text="通过" OnClick="BtnConfirm2_Click" /></td>
            <td rowspan="2">
                <asp:TextBox ID="TextBoxRem2" runat="server" TextMode="MultiLine" Width="100%" Height="100%"></asp:TextBox></td>
        </tr>
        <tr>
            <td>
                <asp:Button ID="BtnRefuse2" runat="server" Text="否决" OnClick="BtnRefuse2_Click" /></td>
        </tr>
    </table>
    <table border="1" width="100%">
        <tr>
            <td align="left">
                <asp:Button ID="BtnBottomReturn" runat="server" Text="返回" OnClick="BtnTopReturn_Click"
                    CausesValidation="False" /></td>
            <td align="right">
                <asp:Button ID="BtnRemoveContract" runat="server" Text="删除合同" OnClick="BtnRemoveContract_Click"
                    OnClientClick='return confirm("您确认删除该合同吗?提示：仅可删除未开始实验的合同。");' Visible="False" /></td>
        </tr>
    </table>
</asp:Content>
